@extends('layouts.back_stage')
@section('style')
    @parent
    <link rel="stylesheet" href="{{env('CDN_DOMAIN_NAME')}}/css/createPro.css"/>
    <style rel="stylesheet">
        .form_add{
            margin:0;
        }
    </style>
@endsection
@section('content')
<div class="container">
    <div class="row">
        <div style="margin:30px;"><h3 >添加波段</h3></div>
        <div style="width:90%;margin-left:100px;">
            <form>
                <div class="form-group">
                    <ul class="form_ul">
                        <li class="form_li">品牌：
                            <select class="sel_inp" name="brand" id="brand">
                                <option value="">请选择</option>
                                @foreach($brands as $k=>$v)
                                    <option value="{{ $k }}">{{ $v }}</option>
                                @endforeach
                            </select>
                        </li>
                    </ul>
                    <ul class="form_ul">
                        <li class="form_li" style="width:500px;">
                            波段名：
                            <input type="text" style="width:300px;display: inline-block" class="form-control" name="title" id="title" placeholder="输入波段名称" maxlength="10">
                        </li>
                    </ul>
                    <ul class="form_ul">
                        <li class="form_li" style="width:500px;">
                            <label>时间：</label>
                            <input class="jcDate form-control reservation_start" name="start_at" id="start_at"   style="margin-left:14px;width: 150px;display: inline-block;" placeholder="开始时间" autocomplete="off"  />
                            <span>-</span>
                            <input class="jcDate form-control reservation_end" name="end_at" id="end_at"  style="width: 150px;display: inline-block;"  placeholder="结束时间" autocomplete="off"  />
                        </li>
                    </ul>
                </div>
                <div class="form-group"><button class='form_add btn btn-success'>添加</button></div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function (){
        $(".jcDate").jcDate({
            IcoClass : "jcDateIco",
            Event : "click",
            Speed : 300,
            Left : 0,
            Top : 28,
            format : "-",
            Timeout : 100000
        });
    });
    $('.form_add').click(function () {
        if($('#brand').val() == ''){
            $(".faceImg").attr("src","/img/weep.png");
            $(".oHandle").text("没有选择品牌");
            $(".oSuccess").show(0).delay(1000).hide(0);
            return false;
        }else if($('#title').val() == ''){
            $(".faceImg").attr("src","/img/weep.png");
            $(".oHandle").text("没有填写波段名");
            $(".oSuccess").show(0).delay(1000).hide(0);
            return false;
        }else if($('#start_at').val() == '' || $('#end_at').val() == ''){
            $(".faceImg").attr("src","/img/weep.png");
            $(".oHandle").text("没有选择时间");
            $(".oSuccess").show(0).delay(1000).hide(0);
            return false;
        }
        $.ajax({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
            },
            url:'/waveband/increaseBand',
            type:'post',
            dataType:'json',
            data:$('form').serialize(),
            success:function (res) {
                console.log(res);
                var matchID = res.info;
                window.location.href = 'addMatch?id='+matchID
            }
        })
    })
</script>
@endsection
@section('style')
    @parent
    <link href="{{env('CDN_DOMAIN_NAME')}}/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="{{env('CDN_DOMAIN_NAME')}}/css/jcDate.css" rel="stylesheet">
    <link href="{{env('CDN_DOMAIN_NAME')}}/css/waveband.css?v0.0.1" rel="stylesheet">
@endsection
@section('script')
    @parent
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/jQuery-jcDate.js" type="text/javascript"></script>
    <script src="https://www.jq22.com/jquery/jquery-migrate-1.2.1.min.js"></script><!--JQ的版本引导-->
@endsection